<?php

/* @var $this View */

use app\widgets\BaseMenuWidget;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\web\View;

$items = [
    [
        'label' => '<i class="icon-search"></i>',
        'linkOptions' => ['class' => 'nav-link nav-link-search'],
        'visible' => Yii::$app->controller->action->id !== 'item'],
    [
        'label' => '<i class="icon-star"></i>',
        'options' => ['class' => 'nav-item popover popover-bottom nav-item-favorite'],
        'append' => $this->render('/favorite')
    ],
    [
        'label' => '<i class="icon-history"></i>',
        'options' => ['class' => 'nav-item popover popover-bottom nav-item-history'],
        'append' => $this->render('/history'),
    ],
    [
        'label' => '<i class="icon-mobile"></i>',
        'options' => ['class' => 'nav-item tooltip tooltip-bottom', 'data-tooltip' => '手机版']
    ]
];

if (Yii::$app->user->isGuest) {
    $items[] = [
        'label' => '<i class="icon-user-circle"></i>',
        'linkOptions' => [
            'class' => 'nav-link ajax-modal ajax-login',
            'data-href' => Url::to(['auth/login'])
        ]
    ];
} else {
    $items[] = [
        'label' => Html::img(Yii::$app->user->getIdentity()->getAvatar()),
        'linkOptions' => ['class' => 'nav-link']
    ];
}

echo BaseMenuWidget::widget(['items' => $items, 'options' => ['class' => 'nav nav-right']]);
